<?php
/**
 * Created by PhpStorm.
 * User: 式神 (luck48.com)
 * Email: 289650682@qq.com
 * Name: CategoryAdministrator
 * Date: 2017-03-23
 * Time: 16:31
 */

namespace App\Http\Models;

use Illuminate\Database\Eloquent\Model;

class Category extends Model
{
    protected $table='categorys';
    protected $primaryKey="id";
    //public $timestamps=false;
    protected $fillable = [
        'name',
        'catdir',
        'image',
        'description',
        'checked',
        'showed',
        'seo_title',
        'seo_keyword',
        'seo_description',
        'links',
        'click',
        'type',
        'listsort',
        'pid',
        'template'
    ];

    /**
     * 获取权限外键
     */
    public function Article()
    {
        return $this->hasMany(Article::class, 'cid','id');
    }

    /*
     * 定义逆向关系指向主键表
     * */
    public function Attr(){
        return $this -> belongsTo(Attr::class,'id');
    }
}